Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend GridSort possibilities #1860

Merged
merged 3 commits into from
Apr 17, 2024
Merged

Conversation

martinbu
Copy link
Contributor

This PR extends missing GridSort overloads including an IComparer

  1. GridSort ByDescending(Expression<Func<TGridItem, U>> expression, IComparer comparer)
  2. GridSort ThenAscending(Expression<Func<TGridItem, U>> expression, IComparer comparer)
  3. GridSort ThenDescending(Expression<Func<TGridItem, U>> expression, IComparer comparer)

Additionally add methods to sort for a second column that is not affected by the sort direction

  1. GridSort ThenAlwaysAscending(Expression<Func<TGridItem, U>> expression)
  2. GridSort ThenAlwaysAscending(Expression<Func<TGridItem, U>> expression, IComparer comparer)
  3. GridSort ThenAlwaysDescending(Expression<Func<TGridItem, U>> expression)
  4. public GridSort ThenAlwaysDescending(Expression<Func<TGridItem, U>> expression, IComparer comparer)

@vnbaaij
Copy link
Collaborator

vnbaaij commented Apr 15, 2024

Hi Martin,

Can you explain why we would need this extensions? Is it for sorting on multiple columns? Because I dont' think the current rendering supports that.

@martinbu
Copy link
Contributor Author

martinbu commented Apr 16, 2024

Hi Vincent,

I need it for the DataGrid SortBy of the TemplateColumn. I have added an example to the PR which demonstrates the use of at least one new extension: .ThenAlwaysAscending(...)

Sorting by multiple columns in DataGrid, at least as far as I can judge, works totally fine.

The other extensions can also be used in this context and should work as expected as demonstrated in the unit test cases.

What seems not yet supported is the use of SortBy in a PropertyColumn, although it is listed in the documentation of the PropertyColumn here:
https://www.fluentui-blazor.net/DataGrid --> PropertyColumn<TGridItem, TProp> Class --> Parameters --> SortBy

So I think the fact that it is listed here but not available can be interpreted as a "bug"?

@martinbu martinbu force-pushed the feature/improve-gridsort branch from 0f28022 to 56e0495 Compare April 16, 2024 16:25
@vnbaaij
Copy link
Collaborator

vnbaaij commented Apr 17, 2024

I think it is shown on PropertyColumn because it uses the same base class (ColumnBase) as TemplateColum

@vnbaaij vnbaaij merged commit 566c696 into microsoft:dev Apr 17, 2024
1 of 2 checks passed
@martinbu
Copy link
Contributor Author

I will check if SortBy can be enabled for PropertyColumn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants